/*  header-comment
/*  file   : /Users/arida/react-hrm-h5/src/actions/holiday/index
/*  author :  
/*  date   : 2017-6-4 18:27:59
/*  last   : 2017-8-2 11:39:2
*/
import { createAction } from "redux-actions";
import fetch from "../../utils/fetch.js";
import { getAllUrlParams } from "../../utils/common.js";

export const getHoliday = createAction("GET_HOLIDAY");

export const getAdminList = createAction("GET_ADMIN_LIST");

export const fetchHoliday = () => dispatch => {
  // 做成自定义的直接从url获取所有参数拼成对象
  dispatch(getHoliday(getAllUrlParams()));
};

export const fetchAdminList = () => dispatch =>
  fetch(`/hrmregister/mobile/admin/getAdminList`, {
    meta: {
      dipId: 63671
    }
  }).then(res => {
    dispatch(getAdminList(res.result));
    return res;
  });

export const fetchEncodeUid = userId => () =>
  fetch(`/hrmregister/mobile/admin/getEncodeUid`, {
    body: { userId },
    meta: {
      dipId: 63672
    }
  }).then(res => res.result);
